<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>编辑任务</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
</head>
<body>
   {% include 'navbar.html' %}
    <div class="container mt-5">
        <h1>编辑任务</h1>
        <form action="{{ url_for('edit_task', task_id=task.id) }}" method="POST">
            <div class="form-group">
                <label for="source_id">选择爬虫源</label>
                <select class="form-control" id="source_id" name="source_id" required>
                    <option value="">请选择爬虫源</option>
                    {% for source in sources %}
                        <option value="{{ source.id }}" {% if source.id == task.source_id %}selected{% endif %}>{{ source.source_name }}</option>
                    {% endfor %}
                </select>
            </div>
            <div class="form-group">
                <label for="book_name">小说名称</label>
                <input type="text" class="form-control" id="book_name" name="book_name" value="{{ task.book_name }}" required>
            </div>
            <div class="form-group">
                <label for="author_name">作者名称</label>
                <input type="text" class="form-control" id="author_name" name="author_name" value="{{ task.author_name }}" required>
            </div>
            <div class="form-group">
                <label for="source_book_id">源站小说ID</label>
                <input type="text" class="form-control" id="source_book_id" name="source_book_id" value="{{ task.source_book_id }}" required>
            </div>
            <div class="form-group">
                <label for="cat_id">分类ID</label>
                <input type="number" class="form-control" id="cat_id" name="cat_id" value="{{ task.cat_id }}" required>
            </div>
            <div class="form-group">
                <label for="task_status">任务状态</label>
                <select class="form-control" id="task_status" name="task_status" required>
                    <option value="0" {% if task.task_status == 0 %}selected{% endif %}>失败</option>
                    <option value="1" {% if task.task_status == 1 %}selected{% endif %}>完成</option>
                    <option value="2" {% if task.task_status == 2 %}selected{% endif %}>待处理</option>
                </select>
            </div>
            <div class="form-group">
                <label for="exc_count">执行次数</label>
                <input type="number" class="form-control" id="exc_count" name="exc_count" value="{{ task.exc_count }}" required>
            </div>
            <button type="submit" class="btn btn-primary">保存更改</button>
        </form>
    </div>

    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.10.2/dist/umd/popper.min.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>
